﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Proggy.Web.Cms.PropertyTypes;
using Newtonsoft.Json;
using Proggy.Web.Cms.Context;

namespace Proggy.Web.Cms.Core.Configuration.ConfigObjects
{
    /// <summary>
    /// Config object for RTE
    /// </summary>
    public class RichTextContentConfigObject : PropertyTypeConfigObjectBase
    {

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string height { get { return this._height; } set { this._height = value; } }
        private string _height = "30em";

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string width { get { return this._width; } set { this._width = value; } }
        private string _width = "61.2em";

        /// <summary>
        /// TinyMCE property - mandatory 
        /// - eg ProggyFrontEndRequestContext.GetRootUrl() + "Content/Css/Site.css",
        /// </summary>
        public string content_css { get; set; }

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string theme { get { return this._theme; } set { this._theme = value; } }
        private string _theme = "advanced";

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string theme_advanced_buttons1 { get { return this._theme_advanced_buttons1; } set { this._theme_advanced_buttons1 = value; } }
        private string _theme_advanced_buttons1 = "bold,italic,formatselect,link,unlink,anchor,table";//,media";

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string theme_advanced_buttons2 { get { return this._theme_advanced_buttons2; } set { this._theme_advanced_buttons2 = value; } }
        private string _theme_advanced_buttons2 = "";

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string theme_advanced_blockformats { get { return this._theme_advanced_blockformats; } set { this._theme_advanced_blockformats = value; } }
        private string _theme_advanced_blockformats = "p,h3,h4,h5";

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string plugins { get { return this._plugins; } set { this._plugins = value; } }
        private string _plugins = "table";//,media";

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string script_url
        {
            get
            {
                // get path to tiny mce
                return FrontEndRequestContext.GetRootUrl() + "Areas/ProggyCore/Content/ThirdParty/tiny_mce/tiny_mce.js";
            }
        }

        /// <summary>
        /// TinyMCE property
        /// </summary>
        public string encoding { get { return "xml"; } }

                /// <summary>
        /// The unique aliases of image container nodes
        /// </summary>
        public string[] ImageFolderUniqueAliases { get; set; }

        /// <summary>
        /// Returns json string of this for RTE config
        /// </summary>
        /// <returns></returns>
        public string GetJsonString()
        {
            // get json
            var jsonString = JsonConvert.SerializeObject(this);

            //
            return jsonString;
        }
    }
}
